package com.ktgj.flight.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ktgj.flight.domain.vo.FlightOverdueTicketVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.flight.domain.FlightOverdueTicket;
import com.ktgj.flight.service.IFlightOverdueTicketService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 逾期未起飞客票Controller
 * 
 * @author ruoyi
 * @date 2022-09-23
 */
@RestController
@RequestMapping("/ticket")
public class FlightOverdueTicketController extends BaseController
{
    @Autowired
    private IFlightOverdueTicketService flightOverdueTicketService;

    /**
     * 查询逾期未起飞客票列表
     */
    @PreAuthorize(hasPermi = "flight:ticket:list")
    @GetMapping("/list")
    public TableDataInfo list(FlightOverdueTicket flightOverdueTicket)
    {
        startPage();
        List<FlightOverdueTicket> list = flightOverdueTicketService.selectFlightOverdueTicketList(flightOverdueTicket);
        return getDataTable(list);
    }

    /**
     * 导出逾期未起飞客票列表
     */
    @PreAuthorize(hasPermi = "flight:ticket:export")
    @Log(title = "逾期未起飞客票", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FlightOverdueTicket flightOverdueTicket) throws IOException
    {
        List<FlightOverdueTicket> list = flightOverdueTicketService.selectFlightOverdueTicketList(flightOverdueTicket);
        ExcelUtil<FlightOverdueTicket> util = new ExcelUtil<FlightOverdueTicket>(FlightOverdueTicket.class);
        util.exportExcel(response, list, "逾期未起飞客票数据");
    }

    /**
     * 获取逾期未起飞客票详细信息
     */
    @PreAuthorize(hasPermi = "flight:ticket:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(flightOverdueTicketService.selectFlightOverdueTicketById(id));
    }

    /**
     * 新增逾期未起飞客票
     */
    @PreAuthorize(hasPermi = "flight:ticket:add")
    @Log(title = "逾期未起飞客票", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FlightOverdueTicket flightOverdueTicket)
    {
        return toAjax(flightOverdueTicketService.insertFlightOverdueTicket(flightOverdueTicket));
    }

    /**
     * 修改逾期未起飞客票
     */
    @PreAuthorize(hasPermi = "flight:ticket:edit")
    @Log(title = "逾期未起飞客票", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FlightOverdueTicket flightOverdueTicket)
    {
        return toAjax(flightOverdueTicketService.updateFlightOverdueTicket(flightOverdueTicket));
    }

    /**
     * 删除逾期未起飞客票
     */
    @PreAuthorize(hasPermi = "flight:ticket:remove")
    @Log(title = "逾期未起飞客票", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(flightOverdueTicketService.deleteFlightOverdueTicketByIds(ids));
    }

    /**
     * 逾期未起飞客票监控列表
     * @param overdueTicket
     * @return
     */
    @PostMapping("/flightOverdueTicketList")
    public TableDataInfo flightOverdueTicketList(@RequestBody FlightOverdueTicketVO overdueTicket) {
        startPage();
        List<FlightOverdueTicket> flightOverdueTickets = flightOverdueTicketService.flightOverdueTicketList(overdueTicket);
        return getDataTable(flightOverdueTickets);
    }
}
